package com.hongyi.system.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.hongyi.common.web.controller.BaseController;
import com.hongyi.common.framework.domain.JsonResult;
import com.hongyi.common.mybatis.page.PageData;
import com.hongyi.common.mybatis.page.PageQuery;
import com.hongyi.system.domain.dto.SysUserNoticeDto;
import com.hongyi.system.domain.vo.SysUserNoticeVo;
import com.hongyi.system.service.ISysUserNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 用户消息关联Controller
 *
 * @author DingHao
 * @date 2025-01-24 13:13:15
 */
@ApiSort(value = 155)
@Api(tags = "用户消息关联控制器")
@RestController
@RequestMapping("/system/userNotice")
public class SysUserNoticeController extends BaseController {

    @Autowired
    ISysUserNoticeService systemUserNoticeService;

    /**
     * 查询用户消息关联分页列表
     * @param systemUserNoticeDto 用户消息关联业务对象
     * @return 用户消息关联分页数据
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询用户消息关联分页列表")
    @ApiImplicitParam(name = "systemUserNotice", value = "用户消息关联业务对象", paramType = "query", dataTypeClass = SysUserNoticeDto.class)
    @GetMapping(value = "/list")
    public PageData<SysUserNoticeVo> list(SysUserNoticeDto systemUserNoticeDto, PageQuery pageQuery) {
        return systemUserNoticeService.querySystemUserNoticeVoPageList(systemUserNoticeDto,pageQuery);
    }

    /**
     * 获取用户消息关联详细信息
     *
     * @param id 用户消息关联主键
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "获取用户消息关联详细信息")
    @ApiImplicitParam(name = "id", value = "用户消息关联主键", paramType = "path", dataTypeClass = Long.class, required = true)
    @GetMapping(value = "/{id}")
    public JsonResult<SysUserNoticeVo> getInfo(@PathVariable("id") Long id) {
        return JsonResult.ok(systemUserNoticeService.querySystemUserNoticeVoById(id));
    }

    /**
     * 查询当前用户未读通知数量
     * @return 未读通知数量
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "查询当前用户未读通知数量")
    @GetMapping(value = "/getMyNoticeCount")
    public JsonResult<Long> getMyNoticeCount() {
        return JsonResult.ok(systemUserNoticeService.queryMyNoticeCount());
    }

    /**
     * 查询当前用户未读通知列表
     * @return 前3个未读通知列表
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查询当前用户未读通知列表")
    @GetMapping(value = "/getMyNoticeList")
    public JsonResult<List<SysUserNoticeVo>> getMyNoticeList() {
        return JsonResult.ok(systemUserNoticeService.queryMyNoticeList());
    }


}
